<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <style>
        .search_input option{font-size:13px;}
        .layui-show .title{margin:10px 0;font-weight: bold;font-size: 14px;float:left}
        .layui-show .sendBtn{float:right}
    </style>
</block>
<block name="content" > 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <form method="get">
                        <!--管理员查询-->
                        <if condition="$flag eq 3">
                            <div class="layui-inline">
                                <span class="btn-upload form-group">
                                    <select name="flowId" class="layui-input search_input" style="width:100px">
                                        <option value="">全部流程</option>
                                        <foreach name="flowCates" item="cate">
                                            <if condition="$cate[sort_id] neq 100">
                                                <option value="{$cate.sort_id}">{$cate.sort_name}</option>
                                                <foreach name="cate.child" item="child">
                                                    <option value="{$child.flow_id}" {$flowId == $child['flow_id'] ? 'selected' : ''}>&nbsp;&nbsp;{$child.flow_name}</option>
                                                </foreach>
                                            </if>
                                        </foreach>
                                    </select>
                                </span>
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="runId" placeholder="流水号" value="{$runId}" class="layui-input search_input">
                            </div>
                            <div class="layui-inline">
                                <span class="btn-upload form-group">
                                    <select name="range" class="layui-input search_input" style="width:100px">
                                        <option value="0" {$range == 0 ? 'selected' : ''}>所有范围</option>
                                        <option value="1" {$range == 1 ? 'selected' : ''}>指定发起人</option>
                                        <option value="2" {$range == 2 ? 'selected' : ''}>指定经办人</option>
                                    </select>
                                </span>
                            </div>
                            <div class="layui-input-inline" id="user" style="display:none;width:250px">
                                <div style="padding-left:6px;width:150px;display:inline-block;background: #fff;line-height: 36px;height: 36px;border: 1px solid #e6e6e6;">
                                    <span class="one-name">
                                        <a>{$userName}</a><input type="hidden" name="user_ids[]" value="{$userId}">
                                    </span>
                                </div>
                                <a class="pointer flowCheckUser" style="display:inline-block">添加&nbsp;</a>
                                <a class="pointer clearData" style="display:inline-block">清空</a>
                                <input type="hidden" id="one" value="1">
                            </div>
                            <div class="layui-inline">
                                <span class="btn-upload form-group">
                                    <select name="prcsFlag" class="layui-input search_input" style="width:100px">
                                        <option value="0" {$prcsFlag == 0 ? 'selected' : ''}>所有状态</option>
                                        <option value="1" {$prcsFlag == 1 ? 'selected' : ''}>正在执行</option>
                                        <option value="2" {$prcsFlag == 2 ? 'selected' : ''}>执行结束</option>
                                    </select>
                                </span>
                            </div>
                        </if>

                        <div class="layui-input-inline">
                            <input type="text" name="runName" placeholder="工作名称" value="{$runName}" class="layui-input search_input">
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="start" placeholder="开始时间" value="{$start}" class="layui-input search_input datepickerInput" style="width:25%;display:inline-block"> 至 <input type="text" name="end" placeholder="结束时间" value="{$end}" class="layui-input search_input datepickerInput" style="width:25%;display:inline-block">
                            <a class="layui-btn search_btn search" data-url="{:U('lists')}"> 查询</a>

                        </div>
                        <input type="hidden" name="type" value="{$flag}">
                    </form>

                </blockquote>
                <div class="layui-tab-content larry-personal-body clearfix mylog-info-box">
                    <!-- 计划列表 -->
                    <div class="layui-tab-item layui-field-box layui-show">
                        <if condition="$flag neq 3">
                        <p class="title">{$flag == 1 ? '未办结工作' : '已办结工作'}</p>
                        <else />
                        <p class="title"><if condition="$prcsFlag neq 0">{$prcsFlag == 1 ? '正在执行' : '执行结束'}<else/>所有工作</if></p>
                        </if>
                        <p class="sendBtn"><a class="layui-btn search_btn" href="{:U('index')}" > 发起流程</a></p>
                        <table class="layui-table table-hover" lay-even="" lay-skin="nob">
                            <thead>
                                <tr>
                                    <th style="width:7%">流水号</th>
                                    <th>工作名称</th>
                                    <th>当前步骤</th>
                                    <th>发起人</th>
                                    <th>办理时间</th>
                                    <th>流程状态</th>
                            <if condition="$flag neq 1">
                                <th>催办</th>
                            </if>
                            <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <if condition="$hasPriv eq false">
                                <tr><td colspan="2" style="border-bottom: 1px solid #fff;border-left: 1px solid #fff;text-align: left">您没有查询权限</td></tr>
                                <else />
                                <notempty name="runs">
                                    <foreach name="runs" item="row" key="key">
                                        <tr>
                                            <td>{$row.run_id}</td>
                                            <td>
                                        <if condition="$flag eq 1">
                                            <a href="{:U('Flow/form',array('id'=>$row['flow_type']['form_id'],'flow_id'=>$row['flow_id'],'run_id'=>$row['run_id'],'currPrcs'=>$row['currPrcs']))}">{$row.run_name}</a>
                                            <else />
                                            <a href="{:U('Flow/showForm',array('id'=>$row['flow_type']['form_id'],'run_id'=>$row['run_id'],'prcs_id'=>$row['flow_run_prcs']['flow_prcs'],'currPrcs'=>$row['currPrcs']))}">{$row.run_name}</a>
                                        </if>
                                        </td>
                                        <td>第{$row.currPrcs}步.{$row.prcs_name}</td>
                                        <td>{$row.begin_user|getChineseName}</td>
                                        <td>{$row.flow_run_prcs.create_time}</td>
                                        <td>{$row['flowCurrStatus'] == 4 ? '<font color="red">已结束</font>' : '<font color="green">进行中</font>'}</td>
                                        <!--已转交未完结的流程,加提醒-->
                                        <if condition="$flag neq 1">
                                            <td>
                                            <if condition="$row['flowCurrStatus'] neq 4 && $flag neq 1">
                                                <if condition="$row['remind'] eq null">
                                                    <a class="ml-5 remind pointer" data-url="{:U('remind',array('id'=>$row['flow_type']['form_id'],'run_id'=>$row['run_id'],'prcs_id'=>$row['flow_run_prcs']['prcs_id'],'flow_name'=>$row['flow_type']['flow_name'],'begin_user'=>$row['begin_user']))}"  title="催办"><img src="/Public/Admin/images/flow_noremind.png"></a>
                                                    <else />
                                                    <a class="ml-5 remind pointer" data-url="{:U('remind',array('id'=>$row['flow_type']['form_id'],'run_id'=>$row['run_id'],'prcs_id'=>$row['flow_run_prcs']['prcs_id'],'flow_name'=>$row['flow_type']['flow_name'],'begin_user'=>$row['begin_user']))}" title="上次催办时间：{$row.remind}"><img src="/Public/Admin/images/flow_remind.png"></a> 
                                                </if>
                                            </if>
                                            </td>
                                        </if>
                                        <td>
                                            <!--进行中的流程-->
                                        <if condition="$flag eq 3 and $row['flowpriv'] eq 1">
                                            <!--管理员操作-->
                                            <a href="{:U('Flow/form',array('id'=>$row['flow_type']['form_id'],'flow_id'=>$row['flow_id'],'run_id'=>$row['run_id'],'currPrcs'=>1,'flowtype'=>'search'))}">编辑</a>
                                            <if condition="$row['flowCurrStatus'] neq 4 && $flag neq 1">
                                                <a class="pointer endFlow" title="强制结束" data-url="{:U('endFlow',array('run_id'=>$row['run_id']))}">结束</a>
                                                <else/>
                                                <a class="pointer repeatFlow" title="从第一步重新开始，之前的数据不可恢复" data-url="{:U('repeatFlow',array('run_id'=>$row['run_id']))}">重走</a>
                                            </if>
                                            <a class="pointer delFlow" title="强制删除" data-url="{:U('delFlow',array('run_id'=>$row['run_id']))}">删除</a>
                                            <else/>
                                            <!--普通用户操作-->
                                            <if condition="$flag eq 1">
                                                <a style="text-decoration:none" href="{:U('form',array('id'=>$row['flow_type']['form_id'],'flow_id'=>$row['flow_id'],'run_id'=>$row['run_id'],'currPrcs'=>$row['currPrcs']))}" title="主办">主办</a> 
                                            </if>
                                            <!--当前步骤为1时，可删除-->
                                            <if condition="$row['currPrcs'] eq 1 && $flag eq 1">
                                                <a style="text-decoration:none" class="ml-5 delete pointer" data-url="{:U('delFlow',array('run_id'=>$row['run_id']))}"  title="删除">删除</a>
                                            </if>
                                        </if>
                                        <a class="download pointer" data-url="{:U('Flow/download',array('id'=>$row['flow_type']['form_id'],'run_id'=>$row['run_id'],'prcs_id'=>$row['flow_run_prcs']['flow_prcs'],'currPrcs'=>$row['currPrcs']))}" data-name="{$row.flow_type.flow_name}({$date})">导出</a>
                                        </td>
                                        </tr>
                                    </foreach>
                                    <else/>
                                    <tr><td colspan="2" style="border-bottom: 1px solid #fff;border-left: 1px solid #fff;text-align: left">暂无数据</td></tr>
                                </notempty>
                            </if>
                            </tbody>
                        </table>
                        <div class="larry-table-page clearfix">
                            <input type='hidden' id="followUrl" value="{:U('attentPlan')}">
                            <!--<a href="javascript:;" class="layui-btn layui-btn-small"><i class="iconfont icon-shanchu1"></i>删除</a>-->
                            <div id="page" class="page">{$page}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</block>
<block name="script">
    <script type="text/javascript" src="/Public/Admin/js/flow.js"></script>
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        $(dateTime(1));
        $(initFlowList());

        $('.search').click(function () {
            $('form').submit();
        })

    </script>    
</block>

